package com.lanou3g.code0510;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "BServlet",urlPatterns = "/b")
public class BServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.addHeader("content-Type","text/html;charset=utf-8");
        //设置请求头  5秒后回到主页
        //定时刷新  我们不需要设置状态码
        //自动的,到时候就自己重定向过去了
        response.setHeader("Refresh","5;URL=/index.jsp");
        /*
        setheader和addheader区别
        addHesder 可以在响应头 一个key对应多个值
        setHesder 不可以, key相同只会保留最后一个值]
        setHeader
        */
        response.getWriter().println("<a href=\"/index.jsp\">5s后回到主页如果没成功点击此处</a>");

    }
}
